home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 October: Mac OS SDK / Dev.CD Oct 00 SDK1.toast / Development Kits / Cross Platform / QuickTime 4.1.2 Windows SDK / CIncludes / FileSigning.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-04-12  |  5.8 KB  |  223 lines  |  [TEXT/R*ch]

  1. /*
  2.      File:        FileSigning.h
  3.  
  4.      Contains:    Apple File Signing Interfaces.
  5.  
  6.      Version:    Technology:    1.0
  7.                  Release:    QuickTime 4.1
  8.  
  9.      Copyright:    (c) 1999 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __FILESIGNING__
  18. #define __FILESIGNING__
  19.  
  20. #ifndef __MACTYPES__
  21.     #include <MacTypes.h>
  22. #endif
  23.  
  24. #ifndef __FILES__
  25.     #include <Files.h>
  26. #endif
  27.  
  28. #ifndef __KEYCHAIN__
  29.     #include <Keychain.h>
  30. #endif
  31.  
  32. #ifndef __CRYPTOMESSAGESYNTAX__
  33.     #include <CryptoMessageSyntax.h>
  34. #endif
  35.  
  36.  
  37. /* Data structures and types */
  38.  
  39.  
  40. #if PRAGMA_ONCE
  41. #pragma once
  42. #endif
  43.  
  44. #ifdef __cplusplus
  45. extern "C" {
  46. #endif
  47.  
  48. #if PRAGMA_IMPORT
  49. #pragma import on
  50. #endif
  51.  
  52. #if PRAGMA_STRUCT_ALIGN
  53.     #pragma options align=mac68k
  54. #elif PRAGMA_STRUCT_PACKPUSH
  55.     #pragma pack(push, 2)
  56. #elif PRAGMA_STRUCT_PACK
  57.     #pragma pack(2)
  58. #endif
  59.  
  60. enum {
  61.     kSecOptionProgress            = 1 << 0,
  62.     kSecOptionShowVerifyUI        = 1 << 1,
  63.     kSecOptionNeverShowUI        = 1 << 2,
  64.     kCertUsageReserved            = 0x7FFFFF00                    /* Last 3 bytes reserved for SecOptions flags */
  65. };
  66.  
  67. typedef UInt32                             SecOptions;
  68. enum {
  69.     kSecSignatureTypeRawPKCS7    = 0,
  70.     kSecSignatureTypeCMS        = 1,
  71.     kSecSignatureTypePGP        = 2                                /* reserved but not implemented */
  72. };
  73.  
  74. typedef UInt32                             SecSignatureType;
  75. enum {
  76.     kSecTrustPolicyCodeSigning    = 0,
  77.     kSecTrustPolicyPersonalFileSigning = 1
  78. };
  79.  
  80. typedef UInt32                             SecTrustPolicy;
  81.  
  82. struct SecProgressCallbackInfo {
  83.     UInt32                             version;
  84.     UInt32                             bytesProcessed;
  85.     UInt32                             totalBytes;
  86.     UInt32                             itemsRemainingToSign;
  87.     UInt32                             totalItemsToSign;
  88.     UInt32                             secondsRemaining;
  89.     UInt32                             secondsElapsed;
  90.     UInt32                             microSecondsPerByte;
  91.     Str255                             fileName;
  92. };
  93. typedef struct SecProgressCallbackInfo    SecProgressCallbackInfo;
  94. typedef CALLBACK_API( OSStatus , SecProgressCallbackProcPtr )(SecProgressCallbackInfo *callbackInfo, void *userContext);
  95. typedef STACK_UPP_TYPE(SecProgressCallbackProcPtr)                 SecProgressCallbackUPP;
  96. #if OPAQUE_UPP_TYPES
  97.     EXTERN_API(SecProgressCallbackUPP)
  98.     NewSecProgressCallbackUPP       (SecProgressCallbackProcPtr userRoutine);
  99.  
  100.     EXTERN_API(void)
  101.     DisposeSecProgressCallbackUPP    (SecProgressCallbackUPP userUPP);
  102.  
  103.     EXTERN_API(OSStatus)
  104.     InvokeSecProgressCallbackUPP    (SecProgressCallbackInfo * callbackInfo,
  105.                                     void *                    userContext,
  106.                                     SecProgressCallbackUPP    userUPP);
  107.  
  108. #else
  109.     enum { uppSecProgressCallbackProcInfo = 0x000003F0 };             /* pascal 4_bytes Func(4_bytes, 4_bytes) */
  110.     #define NewSecProgressCallbackUPP(userRoutine)                     (SecProgressCallbackUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppSecProgressCallbackProcInfo, GetCurrentArchitecture())
  111.     #define DisposeSecProgressCallbackUPP(userUPP)                     DisposeRoutineDescriptor(userUPP)
  112.     #define InvokeSecProgressCallbackUPP(callbackInfo, userContext, userUPP)  (OSStatus)CALL_TWO_PARAMETER_UPP((userUPP), uppSecProgressCallbackProcInfo, (callbackInfo), (userContext))
  113. #endif
  114. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  115. #define NewSecProgressCallbackProc(userRoutine)                 NewSecProgressCallbackUPP(userRoutine)
  116. #define CallSecProgressCallbackProc(userRoutine, callbackInfo, userContext) InvokeSecProgressCallbackUPP(callbackInfo, userContext, userRoutine)
  117. EXTERN_API( OSStatus )
  118. SecSetProgressCallback            (SecProgressCallbackUPP  callbackProc,
  119.                                  void *                    userContext);
  120.  
  121. EXTERN_API( OSStatus )
  122. SecRemoveProgressCallback        (SecProgressCallbackUPP  callbackProc);
  123.  
  124. EXTERN_API( OSStatus )
  125. DefaultSecProgressCallbackProc    (SecProgressCallbackInfo * info,
  126.                                  void *                    userContext);
  127.  
  128. enum {
  129.     kSecDefaultSignatureResID    = 1
  130. };
  131.  
  132. EXTERN_API( OSStatus )
  133. SecMacSignFile                    (FSSpec *                theFile,
  134.                                  KCItemRef                 signingCertificate,
  135.                                  Handle                 sigH,
  136.                                  SecOptions             options,
  137.                                  SecProgressCallbackUPP  progressProc,
  138.                                  void *                    userContext);
  139.  
  140. EXTERN_API( OSStatus )
  141. SecMacSignFileSimple            (FSSpec *                theFile,
  142.                                  KCItemRef                 signingCertificate,
  143.                                  SecOptions             options);
  144.  
  145. EXTERN_API( OSStatus )
  146. SecMacLoadSigPound                (FSSpec *                theFile,
  147.                                  Handle *                resHandle);
  148.  
  149. EXTERN_API( OSStatus )
  150. SecMacRemoveSignature            (FSSpec *                theFile,
  151.                                  SecSignatureType         signatureType,
  152.                                  SInt16                 signatureToRemove);
  153.  
  154. EXTERN_API( OSStatus )
  155. SecMacRemoveAllSignatures        (FSSpec *                theFile,
  156.                                  SecSignatureType         signatureType);
  157.  
  158.  
  159. EXTERN_API( OSStatus )
  160. SecMacVerifyFile                (FSSpec *                theFile,
  161.                                  SecOptions             options,
  162.                                  SecProgressCallbackUPP  progressProc,
  163.                                  void *                    userContext,
  164.                                  SInt16                 signatureToVerify,
  165.                                  CFArrayRef             policyOIDs,
  166.                                  KCVerifyStopOn         stopOn,
  167.                                  SecSignerRef *            signer);
  168.  
  169. EXTERN_API( OSStatus )
  170. SecMacVerifyFileSimple            (FSSpec *                theFile,
  171.                                  SecOptions             options,
  172.                                  SecTrustPolicy         trustPolicy,
  173.                                  SecSignerRef *            signer);
  174.  
  175. EXTERN_API( Boolean )
  176. SecMacHasSignature                (FSSpec *                theFile,
  177.                                  SecSignatureType         signatureType);
  178.  
  179. EXTERN_API( OSStatus )
  180. SecMacFindSignatureToVerify        (FSSpec *                theFile,
  181.                                  SecSignatureType         signatureType,
  182.                                  SInt16 *                signatureToVerify);
  183.  
  184. EXTERN_API( CFArrayRef )
  185. SecMacGetDefaultPolicyOIDs        (SecTrustPolicy         trustPolicy);
  186.  
  187.  
  188. EXTERN_API( OSStatus )
  189. SecMacDisplaySigner                (OSStatus                 inputErr,
  190.                                  SecSignerRef             signer,
  191.                                  Boolean                 alwaysShowUI,
  192.                                  FSSpec *                theFile);
  193.  
  194. /* Errors Codes */
  195. enum {
  196.     errSecTooManySigners        = -13839,
  197.     errSecSigningFailed            = -13838,
  198.     errSecCorruptSigPound        = -13837,
  199.     errSecNoSignatureFound        = -13836
  200. };
  201.  
  202.  
  203. #if PRAGMA_STRUCT_ALIGN
  204.     #pragma options align=reset
  205. #elif PRAGMA_STRUCT_PACKPUSH
  206.     #pragma pack(pop)
  207. #elif PRAGMA_STRUCT_PACK
  208.     #pragma pack()
  209. #endif
  210.  
  211. #ifdef PRAGMA_IMPORT_OFF
  212. #pragma import off
  213. #elif PRAGMA_IMPORT
  214. #pragma import reset
  215. #endif
  216.  
  217. #ifdef __cplusplus
  218. }
  219. #endif
  220.  
  221. #endif /* __FILESIGNING__ */
  222.  
  223.